Skip to content

fix(examples): update installation instructions + cors origin url#1150

Closed
divyagnan wants to merge 516 commits intorivet-dev:mainfrom
divyagnan:main
Closed

fix(examples): update installation instructions + cors origin url#1150
divyagnan wants to merge 516 commits intorivet-dev:mainfrom
divyagnan:main

Conversation

@divyagnan
Copy link
Copy Markdown

Related: #1140

Why

Tried to run the examples from a fresh git clone using the existing example instructions and wasn't able to.

  1. Running npm install gave the following error:
npm error code EUNSUPPORTEDPROTOCOL
npm error Unsupported URL Type "workspace:": workspace:*
  1. One of the example readmes actually had pnpm install so I tried that and it worked.
  2. However then running the dev command still failed due to not being able to find the @rivetkit/react package:
 npm run dev                                                                                                            

> example-game@0.9.8 dev
> concurrently "tsx --watch src/backend/server.ts" "vite"

[0]
[0] node:internal/modules/run_main:122
[0]     triggerUncaughtException(
[0]     ^
[0] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/dk/Code/experiments/rivetkit/examples/game/node_modules/@rivetkit/actor/dist/mod.js' imported from /Users/dk/Code/experiments/rivetkit/examples/game/src/backend/registry.ts
[0]     at finalizeResolution (node:internal/modules/esm/resolve:257:11)
[0]     at moduleResolve (node:internal/modules/esm/resolve:913:10)
[0]     at defaultResolve (node:internal/modules/esm/resolve:1037:11)
[0]     at nextResolve (node:internal/modules/esm/hooks:748:28)
[0]     at resolveBase (file:///Users/dk/Code/experiments/rivetkit/node_modules/.pnpm/tsx@4.20.3/node_modules/tsx/dist/esm/index.mjs?1753903454156:2:3811)
[0]     at resolveDirectory (file:///Users/dk/Code/experiments/rivetkit/node_modules/.pnpm/tsx@4.20.3/node_modules/tsx/dist/esm/index.mjs?1753903454156:2:4310)
[0]     at resolveTsPaths (file:///Users/dk/Code/experiments/rivetkit/node_modules/.pnpm/tsx@4.20.3/node_modules/tsx/dist/esm/index.mjs?1753903454156:2:5051)
[0]     at resolve (file:///Users/dk/Code/experiments/rivetkit/node_modules/.pnpm/tsx@4.20.3/node_modules/tsx/dist/esm/index.mjs?1753903454156:2:5428)
[0]     at nextResolve (node:internal/modules/esm/hooks:748:28)
[0]     at Hooks.resolve (node:internal/modules/esm/hooks:240:30) {
[0]   code: 'ERR_MODULE_NOT_FOUND',
[0]   url: 'file:///Users/dk/Code/experiments/rivetkit/examples/game/node_modules/@rivetkit/actor/dist/mod.js'
[0] }
[0]
[0] Node.js v22.11.0
[0] Failed running 'src/backend/server.ts'
[1]
[1]   VITE v5.4.19  ready in 640 ms
[1]
[1]   ➜  Local:   http://localhost:3000/
[1]   ➜  Network: use --host to expose
[1] Error:   Failed to scan for dependencies from entries:
[1]   /Users/dk/Code/experiments/rivetkit/examples/game/src/frontend/index.html
[1]
[1]   ✘ [ERROR] Failed to resolve entry for package "@rivetkit/react". The package may have incorrect main/module/exports specified in its package.json. [plugin vite:dep-scan]
  1. I was able to fix this by running pnpm run build from the root directory of the repo.
  2. After getting everything installed and running some of the examples still didn't work — I was getting this cors error (in the browser):
Access to fetch at 'http://localhost:8080/registry/actors/resolve' from origin 'http://localhost:3000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'http://localhost:5173' that is not equal to the supplied origin. Have the server send the header with a valid value.
  1. Saw that some of the examples have an explicitly defined vite config to run the server at localhost:3000 (rather than the default which is localhost:5173). Updating the cors origin url in the server.ts files for these examples fixed the issue and made them work.

What does this PR do

  1. Updates the example README.md files (for all examples) with the instructions that worked
  2. Update the examples with the vite server url and cors origin url mismatches to match

Put them in separate commits bc you could also update the vite.config.ts server port url to fix the issue instead of updating the cors origin url in server.ts. Wasn't sure which would be preferred — seemed like the newer examples use the explicit port 3000 so decided to update the cors url.

prathamdby and others added 30 commits April 3, 2025 12:35
…#804)

* feat: migrate custom scripts and styles for ActorCore documentation

* feat: revamp the features comparison table

* feat: correct the color for hover

* feat: add gradient background style for code blocks

* feat: update background style for platform cards with a gradient effect

* feat: reduce card group columns for consistent layout

* feat: adjust features layout for consistency

* feat: remove the overflow-causing padding on the code block.

* feat: make the hero buttons full-width on mobile

Make the copy button be visible by default on mobile.
Release-As: 0.7.8
Release-As: 0.7.9
* Add `get-port` as dev dep

In rivet-dev#790 `get-port` was added to [`packages/actor-core/src/test/mod.ts`](packages/actor-core/src/test/mod.ts)

Get an error when you run the example

```sh
npx create-actor@0.7.9
npm run test
```

```
➜ npm run test

> counter@0.0.0 test
> vitest run


 RUN  v3.1.1 /Users/username/git/actor-core-counter


⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  tests/counter.test.ts [ tests/counter.test.ts ]
Error: Cannot find package 'get-port' imported from /Users/username/git/actor-core-counter/node_modules/actor-core/dist/test/mod.js
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯


 Test Files  1 failed (1)
      Tests  no tests
   Start at  14:59:12
   Duration  209ms (transform 24ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 35ms)
```

* How embarassing

* Update yarn.lock
jog1t and others added 25 commits July 24, 2025 04:25
rivet-dev#1122)

### TL;DR

Removed database dependencies from the counter example and simplified the actor state structure.

### What changed?

- Removed database integration from the counter example:
  - Deleted `dizzle.config.ts` and `schema.ts` files
  - Removed database-related dependencies from `package.json` (drizzle-orm, better-sqlite3, drizzle-kit)
  - Removed `@rivetkit/db` dependency
- Simplified the counter example's actor state to only include the essential `count` property
- Removed the database initialization and unused code in the registry
- Updated the file system global state implementation to improve actor state loading
- Enhanced the inspector API to support both patching and replacing state
- Updated Zod import to use v4
- Added error handling for actor fetching in the manager inspector

### How to test?

1. Run the counter example to verify it works without database dependencies:
   ```
   cd examples/counter
   pnpm install
   pnpm start
   ```
2. Test the inspector API's new state replacement functionality by making a PATCH request with a `replace` property
3. Verify that actor state loading works correctly with the updated implementation

### Why make this change?

This change simplifies the counter example by removing unnecessary database dependencies, making it more focused on demonstrating the core actor functionality. It also improves the state management implementation and enhances the inspector API with better error handling and the ability to completely replace state, providing more flexibility for debugging and development.
Release-As: 0.9.5
Release-As: 0.9.6
Release-As: 0.9.7
Release-As: 0.9.8
@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Jul 30, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants